package com.tripreset.todo

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import kotlinx.coroutines.flow.Flow

object TodoDaoProvider {

    fun todoDao() = TodoAppDatabase.instance?.getTodoDao()
}

@Dao
interface TodoDao {
    @Query("SELECT * FROM t_todo")
    fun getPlants(): Flow<List<TodoEntity>>

    @Query("SELECT * FROM t_todo WHERE id =:todoId")
    fun getPlant(todoId: String): Flow<TodoEntity>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertAll(plants: List<TodoEntity>)
}